<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>组件的嵌套</title>
    <!--引入vue-->
    <script type="text/javascript" src="../js/vue.js"></script>
</head>

<body>
<div id="root">
</div>

</body>
<script type="text/javascript">
    Vue.config.productionTip = false;
    // 定义student组件
    const student = Vue.extend({
        name: 'student',
        template: `
          <div>
          <h1>学生姓名:{{ studentName }}</h1>
          <h1>年龄:{{ age }}</h1>
          </div>
        `,
        data() {
            return {
                studentName: '兔球儿',
                age: '23'
            }
        }
    })

    // 1、定义school组件
    const school = Vue.extend({
        name: 'school',
        components: {
            student
        },
        template: `
          <div>
          <h1>学校名称:{{ schoolName }}</h1>
          <h1>学校地址:{{ address }}</h1>
          <student></student>
          </div>
        `,
        data() {
            return {
                schoolName: '尚硅谷',
                address: '北京昌平'

            }
        }
    })

    // 定义hello组件
    const hello = Vue.extend({
        template: `
          <div><h1>{{ msg }}</h1></div>`,
        data() {
            return {
                msg: '欢迎兔球儿学习vue!'
            }
        }

    })


    // 定义app组件
    const app = Vue.extend({
        template: `
          <div>
          <hello></hello>
          <school></school>
          </div>
        `,
        components: {school, hello}
    })
    new Vue({
        template: `
          <app></app>`,
        el: '#root',
        data: {},
        // 注册组件(局部)
        components: {
            app
        }
    })
</script>

</html>